package com.sumainfor.common.UnionPay;

import com.google.gson.Gson;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;


/*
*@Author:Gavin
*@Email:gavinsjq@sina.com
*@Date:  2017/12/12
*@Param
*@Description:
*/
public class MapUtil {

    public static Map<String,Object> str2Map(String data){
        Gson gson = new Gson();
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map = gson.fromJson(data, map.getClass());
        return map;
    }



    public static void cleanNull(Map map) {
        Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Object> entry = it.next();
            String key = entry.getKey();
            Object value = entry.getValue();
            if (null == value || value.equals("")) {
                it.remove();
            }
        }
    }



}
